/// @tags:
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 1e6 + 2, mod = 1e9 + 7;

int f[maxn], ans[maxn];

int main() {
  int t;
  cin >> t;
  f[0] = 1;
  for (int i = 1; i < maxn; ++i) {
    f[i] = f[i - 1] * 2 % mod;
  }
  for (int i = 1; i < maxn; ++i) {
    for (int j = 2; j * i < maxn; ++j) {
      f[j * i] -= f[i];
      if (f[j * i] < 0) f[j * i] += mod;
    }
  }
  for (int i = 1; i < maxn; ++i) {
    for (int j = 2; j * i < maxn; ++j) {
      (ans[i * j] += f[i]) %= mod;
    }
  }
  while (t--) {
    int k;
    cin >> k;
    cout << ans[k] << '\n';
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("G. K-Binary Repetitive Numbers.in", "r", stdin);
  freopen("G. K-Binary Repetitive Numbers.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
